%{
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "tableau.h"
int numLigne = 1;
char * argument;
int passage= 0;
int nbC;
%}
blancs				[ \t]+
chiffre   			[0-9]
entier   	 		{chiffre}+
reel                            {entier}|{entier}.{entier}
mot                             [a-zA-Z ]+
commentaire			%.*
tabulation                      \{[\|][c|l|r|\|]*[\|]\}		
%%
"\n"	                       {numLigne++;}
{commentaire}                  /*On ignore les commentaires*/
{blancs}                       /*On ignorer les blancs */
{entier}                       { yylval.ival=atoi(yytext);
	     			return(NOMBRE); }
{reel}	    			{ yylval.fval=atof(yytext);
	     			 return(REEL); }
{mot}    			{strcpy(yylval.cval,yytext);
		                 return(MOT); }
"\\begin{table}" 		{ return (DEBUT_TABLE); }
"\\begin{center}" 		{ return (DEBUT_CENTER); }
"\\begin{tabular}" 		{ return (DEBUT_TABULAR); }
"\\end{tabular}" 		{ return (FIN_TABULAR); }
"\\end{center}" 		{ return (FIN_CENTER); }
"\\end{table}" 			{ return (FIN_TABLE); }
"\\multicolumn" 		{ return (MULTICOLUMN); }
"\\\\" 				{ return (DOUBLE_BS); }
{tabulation} {if(!passage){	
			int i=0,j=0;
			int prem=1;
			argument=malloc(sizeof(char));
			while(yytext[i]!='\0'){
				if(yytext[i]=='c'||yytext[i]=='l'||yytext[i]=='r'){
					if(prem){
						argument=malloc(sizeof(char));
						*argument=yytext[i];
						j++;
						prem=0;	
					}else{
						j++;
					 	argument=realloc(argument,sizeof(char)*j);
						argument[j-1]=yytext[i];				
					 }
				}
				i++;
			}
			nbC=j;
			passage=1;
		}

		 strcpy(yylval.cval,yytext);
			return (TABULATION);}
"\\hline" 		{ return (HLINE);}
"&" 			{ return (ET); }
"{" 			{ return (AO); }
"}" 			{ return (AF); }
"\\" 			{ return (BS); }
"*"  			{ return (ETOILE);}
","  			{ return (VIRGULE);}
"$" 			{ return (DOLLAR);}
"\\bf" 			{return (BF);}
"\\caption" 		{return (CAPTION);}
%%




